home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_01_07 / 1n07037a < prev    next >
Text File  |  1990-10-29  |  1KB  |  49 lines

  1.         
  2. LISTING 7
  3. /* Routine to send a string character to the remote host and get a response
  4. back. 
  5. */
  6.  
  7. #define EVER ;;
  8. #define SEND_RETRY 12
  9. void send_data(void)
  10. {
  11.     int     retry;
  12.     int     len;
  13.     int     done = FALSE;            /* done == 0 */
  14.     char    inbuf[81];
  15.     char    choice[81];             /* Operator choice */
  16.  
  17.     /* Try to deliver character message; if no reply, send again (Send_RETRY times)
  18.     */
  19.     while (EVER) {
  20.         retry = SEND_RETRY;
  21.         puts("Enter Character/String to Transmit: _");
  22.         scanf("%s",choice);
  23.         while (retry--) {
  24.             if (net_write(nd, choice, strlen(choice)+1, 0) < 0) {
  25.                 pneterror("net_write");
  26.                 printf("Send: error on attempt to transmit.\n");
  27.                 get_network_stats(retry);
  28.                 break;
  29.             }
  30.             /* When we get data back, print it out. */
  31.             if ((len = net_read(nd, inbuf, sizeof(inbuf),
  32.                     (struct addr *)0, 0)) >= 0) {
  33.                 get_network_stats(retry);
  34.                 break;
  35.             } else if (neterrno != NET_ERR_TIMEOUT) {
  36.                 pneterror("net_read");
  37.                 printf("Send: error on attempt to receive.\n");
  38.                 get_network_stats(retry);
  39.                 break;
  40.             }
  41.         }                /* no successful attempts */
  42.     } /* end of while (EVER) */
  43.     return;
  44. }
  45.  
  46.  
  47.  
  48.  
  49.